﻿@model HanGu.Entity.Message
@{
    Layout = null;
    TempData["Remark"] = Model.Remark;
    var Attachments = ViewData["Attachments"] as List<HanGu.Entity.FileManage> ?? new List<HanGu.Entity.FileManage>();
    var action = Request["action"];
    var read = action != null && action == "read";
}
<div class="pageContent">
    <style>
        #FileInputUploader
        {
            padding-left: 130px;
        }
    </style>
    <script>
        function onallcomplete(event, id, fileObj, response, data) {


        }
        function uploadifyComplete(event, queueId, fileObj, response, data) {
            //            var html = "<div class='uploadedFile'>" + fileObj.name + "</div>";
            //            $("#uploadedFile").html($("#uploadedFile").html() + html);
            DWZ.ajaxDone(DWZ.jsonEval(response));
            RefreshFiles();

        }
        function RefreshFiles() {
            $("#uploadedFile").loadUrl('/FileManage/index/@Model.GUID?action=@Request["action"]');
        }
        $(function () {
            RefreshFiles();
        });
        function myAjaxDoDone(json) {
            DWZ.ajaxDone(json);
            if (json.statusCode == DWZ.statusCode.ok) {
                RefreshFiles();
            }
        }
       
    </script>
    </script>
    <form method="post" id="SendEmailForm" action="/Message/Default/Email?OpID=@ViewData["OperateID"]" enctype="MULTIPART/FORM-DATA"
    class="pageForm required-validate" onsubmit="return iframeCallback(this, navTabAjaxDone);">
    @Html.ValidationSummary(true)
    <div class="pageFormContent" layouth="56" id="needSendContent">
        @Html.HiddenFor(model => model.ID)
        @Html.HiddenFor(model => model.Type)
        @Html.Hidden("Email.MemberID", Model.MemberID)
        @Html.Hidden("MemberIDs", Request["membersID"])
        @Html.Hidden("SendingCount", Request["SendingCount"])
        @Html.HiddenFor(model => model.CreateTime)
        @Html.HiddenFor(model => model.Creator)
        @Html.HiddenFor(model => model.GUID)
        @Html.Hidden("actiontype", Request["actiontype"])
        @* <p style="width: 100%; height: 60px">
            <label>
                接收组：</label>
            @Html.TextArea("Email.Receiver", Model.Receiver, new { @class = "required", style = "width:600px;height:50px" })
            <a class="btnLook" href="/CustomerGroup/Default/Selecter?lookup=Email" lookupgroup="Email">
                选择会员</a>
            @Html.ValidationMessageFor(model => model.Receiver)
        </p>*@
        <p style="width: 100%">
            <label>
                标题：</label>
            @Html.TextBoxFor(model => model.Title, new { @class = "required", style = "width:400px" })
            @Html.ValidationMessageFor(model => model.Receiver)
        </p>
        @if (Request["action"] != "view")
        {
            <label>
                附件：
            </label>
        
            <div id="fileQueue" class="fileQueue">
            </div>
            <input id="FileInput" type="file" name="image" uploader="/Content/uploadify/scripts/uploadify.swf"
            cancelimg="Content/uploadify/cancel.png" script="/FileManage/SaveFiles" scriptdata="{ClassType:'Temp', guid:'@Model.GUID',GroupName:''}"
            filequeue="fileQueue" onallcomplete="uploadifyComplete" fileExt="*.*" fileDesc="*.*"/>
        }
        <div class="divider">
        </div>
       @* <p style="width: 130px">
            <label>
                已上传附件：</label>*@
            <div id="uploadedFile">
                @* @if (Attachments != null && Attachments.Count > 0)
                {
                    foreach (var item in Attachments)
                    { 
                    <div>
                        <span><a href="@item.FilePath" target="_blank">@item.FilePath</a></span><span style=" padding-left:20px">删除</span></div>
                    }
                }*@
            </div>
       @* </p>*@
        <p style="width: 100%; height: 200px">
            <label>
                内容：</label>
            @Html.Partial("Editor", new HanGu.Entity.EditorDTO() { CrontrollID = "Remark", Value = Model.Remark })
            @Html.ValidationMessageFor(model => model.Remark)
        </p>
    </div>
    @if (Request["action"] != "view")
    {
        <div class="formBar">
            <ul>
                @if (!read)
                {
                    <li>
                        <div class="buttonActive">
                            <div class="buttonContent">
                                <button type="submit" onclick="return ConfirmForm()">
                                    提交</button></div>
                        </div>
                    </li>
                }
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" class="close">
                                取消</button></div>
                    </div>
                </li>
            </ul>
        </div>
    }
    </form>
    <script>
        function ConfirmForm() {
            var memberIDs = $("#SendEmailForm #MemberIDs").val();
            var SendingCount=$("#SendEmailForm #SendingCount").val();
            if (memberIDs == null || memberIDs.length == 0) {
                alertMsg.error("未选择任何客户或所选择的客户不接收邮件!");
            }
            else {
                var isValidate = $("#SendEmailForm").validate().form();
                if (isValidate) {
                    $.pdialog.open("/Message/Default/Confirm?isShowCondition=@Request["isShowCondition"]&form=SendEmailForm&action=confirm&total=" + SendingCount, "SendMessageConfirm", "确认发送？", { max: true, height: 300, width: 580 });
                }
            }
            return false;
        }
       
    </script>
</div>
